/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package five.philosophers;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author mateusz.ledzewicz
 */
public class Checker extends Thread{
    
    public boolean run = true;
    @Override
    public void run(){
        while(run){
            Philosopher current = null;
            try {
                for(Philosopher p : IdMemory.getPhilosophers())
                { 
                    if(current != null){
                        if(p.state == 2 && current.state == 2){
                                throw new Exception("Not good");
                        }
                    }
                    current = p;
                   // System.out.print(p.state + " ");
                }
            } catch (Exception ex) {
                Logger.getLogger(Checker.class.getName()).log(Level.SEVERE, null, ex);
            }
            //System.out.println(" ");
        }
    }
}
